<template>
  <div class="risk app-container">
    <div class="mb8" >
      <el-form v-show="showSearch" :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
        <el-form-item label="用户ID"  prop="memberId">
          <el-input v-model="queryParams.memberId" placeholder="请输入用户ID" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <!-- <el-form-item label="红包口令">
          <el-input v-model="queryParams.code" placeholder="请输入红包口令" clearable @keyup.enter.native="handleQuery" />
        </el-form-item> -->
        <!-- <el-form-item label="类型" prop="noticeType">
          <el-select v-model="queryParams.type" placeholder="红包类型" clearable>
            <el-option v-for="dict in dict.type.redp_packets_type" :key="dict.value" :label="dict.label"
              :value="dict.value" />
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="领取时间" prop="startTime">
          <el-date-picker clearable v-model="queryParams.startCreateDate" type="daterange" value-format="yyyy-MM-dd"
            >
          </el-date-picker>
        </el-form-item> -->
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <right-toolbar class="mb8" :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </div>

    <el-table v-loading="loading" :data="list" style="width: 100%;">
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="红包码" align="center" prop="code" />
      <el-table-column label="用户ID" align="center" prop="memberId" />
      <el-table-column label="账号" align="center" prop="member" >
        <template slot-scope="scope">
          <span v-if="scope.row.member">{{ scope.row.member.phone  || scope.row.member.mail}}</span>
        </template>
      </el-table-column>
      <el-table-column label="红包金额" align="center" prop="amt" />
      <el-table-column label="领取时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createDate) }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"  @pagination="getList"/>

  </div>
</template>

<script>
import { getreadPacketHistory } from "@/api/system/readPacket";

export default {
  name: "redPacketsList",
  data() {
    return {
      // 表单参数
      form: {},
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      title: '',
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        memberId: undefined,
        status: 2,
      },
      // 显示搜索条件
      showSearch: true,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      getreadPacketHistory(this.queryParams).then(response => {
        this.list = response.data.rows;
        this.total = response.data.total|| 0;
        this.loading = false;
      });
    },


    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },


  }
};
</script>
